import logging
from datetime import datetime
from config.config import MORNING_START, MORNING_END

logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)

class DataProcessor:
    @staticmethod
    def is_weekend():
        """判断当前是否为周末"""
        return datetime.now().weekday() >= 5
    
    @staticmethod
    def is_morning_time():
        """判断当前是否在早上指定时间范围内"""
        current_time = datetime.now().strftime("%H:%M")
        logger.debug(f"当前时间: {current_time}, 目标时间范围: {MORNING_START}-{MORNING_END}")
        return MORNING_START <= current_time < MORNING_END
    
    @staticmethod
    def process_sensor_data(temp, humidity, pressure):
        """处理传感器数据"""
        if None in (temp, humidity):
            logger.warning("传感器数据读取不完整")
            return None
            
        return {
            'temperature': temp,
            'humidity': humidity,
            'pressure': pressure
        }